package org.ocean.general.sample.provider;

import org.apache.ibatis.mapping.MappedStatement;
import org.ocean.general.sample.helper.MapperHelper;
import org.ocean.general.sample.helper.MapperTemplate;
import org.ocean.general.sample.helper.OptionalProviderHelper;
import org.ocean.general.sample.helper.ScriptProviderHelper;

public class SelectOptionalProvider<T> extends MapperTemplate {

    public SelectOptionalProvider(Class<?> mapperClass, MapperHelper mapperHelper) {
        super(mapperClass, mapperHelper);
    }

    public String selectJoinListByConditional(MappedStatement mappedStatement){
        return "";
    }
    public String selectJoinSpecifyResultListByConditional(MappedStatement mappedStatement){
        return "";
    }
    public String selectJoinByConditional(MappedStatement mappedStatement){
        return "";
    }
    public String selectJoinSpecifyResultByConditional(MappedStatement mappedStatement){
        return "";
    }

    public String selectList(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        return ScriptProviderHelper.selectCommonScript(cla);
    }

    public String selectByPrimaryKey(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        return  ScriptProviderHelper.singleSelectPrimaryKeyScript(cla);
    }
    public String selectByIds(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        return  ScriptProviderHelper.singleSelectPrimaryMoreKeyScript(cla);
    }


    public String selectByConditional(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        return ScriptProviderHelper.selectCommonConditionalScript(cla);
    }

    public String selectByCountSql(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        return ScriptProviderHelper.singleSelectCountScript(cla);
    }
    public String selectByCount(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        return ScriptProviderHelper.singlePureSelectCountScript(cla);
    }
    public String selectByConditionalCount(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        return ScriptProviderHelper.singleSelectCountByConditionalScript(cla);
    }
    public String selectBetweenByCountSql(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        return ScriptProviderHelper.singleSelectBetweenCountScript(cla);
    }

    public String  selectPageByConditional(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        return ScriptProviderHelper.listSelectPageScript(cla);
    }

    public String  selectPageBySpecifyWhere(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        return ScriptProviderHelper.listSelectPageSpecifyScript(cla);
    }

    public String  selectBetweenPageByPrimaryKey(MappedStatement mappedStatement){
        Class<?> cla = getEntityClass(mappedStatement);
        setResultType(mappedStatement,cla);
        String primaryKey = OptionalProviderHelper.findPrimaryKey(getEntityClass(mappedStatement));
        return ScriptProviderHelper.listSelectBetweenPageScript(cla,primaryKey);
    }
}
